﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace XtremBiking.Logica
{
    /// <summary>
    /// Internal static class responsible to provide common utilities for the rest of the system classes
    /// </summary>
    internal static class Utilities
    {

        #region GeneratePassword
        /// <summary>
        /// Method responsible for generating a random password based on a predetermined length from a parameter "passwordLength" and returned
        /// </summary>
        /// <returns>String containing a random password</returns>
        internal static string GeneratePassword()
        {
            int passwordLength = 8;// int.Parse(ConfigurationManager.AppSettings["passwordLength"]);

            System.Text.StringBuilder sbPassword = new System.Text.StringBuilder("");
            char character;

            System.Random myRandom = new Random();
            string[] charsArray = new string[31] { "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "X", "Y", "Z" };
            while (sbPassword.Length < passwordLength)
            {
                character = Convert.ToChar(charsArray[(myRandom.Next(0, 30))]);
                sbPassword.Append(character);
            }

            return sbPassword.ToString();
        } 
        #endregion

    }
}
